package com.caiback.controller;

import com.caiback.pojo.Result;
import com.caiback.pojo.User;
import com.caiback.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.jws.soap.SOAPBinding;
import java.util.List;

/**
 * 用户控制
 */
@Slf4j
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/list")
    public Result list(){
        log.info("用户列表");

        List<User> userlist = userService.list();

        return Result.success(userlist);
    }


    /**
     * 个人资料编辑
     * @param user
     * @return
     */
    @PutMapping("/edit")
    public Result introPost(@RequestBody User user){
        log.info("个人资料编辑:{}",user);

        userService.edit(user);

        return Result.success();
    }

    @GetMapping("/person")
    public User introGrt(Integer id){
        log.info("展现个人信息");

        User u = userService.introGet(id);

        return u;
    }
}
